/*
 * This file is part of the HZZFWebImage package.
 * (c) Olivier Poitrey <>
 * (c) Fabrice Aneche
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#import <Foundation/Foundation.h>
#import "HZZFWebImageCompat.h"

/**
 You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value.
 For custom coder plugin, it can also extern the enum for supported format. See `HZZFImageCoder` for more detailed information.
 */
typedef NSInteger HZZFImageFormat NS_TYPED_EXTENSIBLE_ENUM;
static const HZZFImageFormat HZZFImageFormatUndefined = -1;
static const HZZFImageFormat HZZFImageFormatJPEG      = 0;
static const HZZFImageFormat HZZFImageFormatPNG       = 1;
static const HZZFImageFormat HZZFImageFormatGIF       = 2;
static const HZZFImageFormat HZZFImageFormatTIFF      = 3;
static const HZZFImageFormat HZZFImageFormatWebP      = 4;
static const HZZFImageFormat HZZFImageFormatHEIC      = 5;
static const HZZFImageFormat HZZFImageFormatHEIF      = 6;
static const HZZFImageFormat HZZFImageFormatPDF       = 7;
static const HZZFImageFormat HZZFImageFormatSVG       = 8;
static const HZZFImageFormat HZZFImageFormatBMP       = 9;
static const HZZFImageFormat HZZFImageFormatRAW       = 10;

/**
 NSData category about the image content type and UTI.
 */
@interface NSData (HZZFImageContentType)

/**
 *  Return image format
 *
 *  @param data the input image data
 *
 *  @return the image format as `HZZFImageFormat` (enum)
 */
+ (HZZFImageFormat)hzzf_imageFormatForImageData:(nullable NSData *)data;

/**
 *  Convert HZZFImageFormat to UTType
 *
 *  @param format Format as HZZFImageFormat
 *  @return The UTType as CFStringRef
 *  @note For unknown format, `kHZZFUTTypeGIFImage` abstract type will return
 */
+ (nonnull CFStringRef)hzzf_UTTypeFromImageFormat:(HZZFImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(cxh_UTType(from:));

/**
 *  Convert UTType to HZZFImageFormat
 *
 *  @param uttype The UTType as CFStringRef
 *  @return The Format as HZZFImageFormat
 *  @note For unknown type, `HZZFImageFormatUndefined` will return
 */
+ (HZZFImageFormat)hzzf_imageFormatFromUTType:(nonnull CFStringRef)uttype;

@end
